package com.iphanta.community.user.service.impl;

import com.baidu.fsg.uid.UidGenerator;
import com.iphanta.community.user.entity.UserBasicInfo;
import com.iphanta.community.user.mapper.UserBasicInfoMapper;
import com.iphanta.community.user.service.TestUserService;
import com.iphanta.community.user.traffic.UserRegisterRequest;
import com.iphanta.community.user.traffic.UserRegisterResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author 墨声 E-mail: zehong.hongframe.huang@gmail.com
 * create time: 3/2/22 7:05 PM
 */
@Service
public class TestUserServiceImpl implements TestUserService {

    @Autowired
    private UserBasicInfoMapper userBasicInfoMapper;

    @Autowired
    private UidGenerator uidGenerator;

    @Override
    public UserRegisterResponse testRegister(UserRegisterRequest request) {
        UserRegisterResponse response = new UserRegisterResponse();
        for (int i = 101100; i < 103100; i++) {
            UserBasicInfo brandnew = new UserBasicInfo();
            brandnew.setId(this.uidGenerator.getUID());
            brandnew.setUid(String.valueOf(i));
            brandnew.setNickname(request.getNickname() + "_" + i);
            this.userBasicInfoMapper.insert(brandnew);
        }

        response.setBrandNew(true);
        return response;
    }
}
